<?php

/**
 * Address form base class.
 *
 * @method Address getObject() Returns the current form's model object
 *
 * @package    HomeShow
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseAddressForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'         => new sfWidgetFormInputHidden(),
      'street'     => new sfWidgetFormInputText(),
      'city'       => new sfWidgetFormInputText(),
      'state'      => new sfWidgetFormInputText(),
      'zip'        => new sfWidgetFormInputText(),
      'type'       => new sfWidgetFormChoice(array('choices' => array('Home' => 'Home', 'Work' => 'Work', 'Show' => 'Show', 'Other' => 'Other'))),
      'preferred'  => new sfWidgetFormInputCheckbox(),
      'contact_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Contact'), 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'id'         => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'street'     => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'city'       => new sfValidatorString(array('max_length' => 20, 'required' => false)),
      'state'      => new sfValidatorString(array('max_length' => 2, 'required' => false)),
      'zip'        => new sfValidatorString(array('max_length' => 10, 'required' => false)),
      'type'       => new sfValidatorChoice(array('choices' => array(0 => 'Home', 1 => 'Work', 2 => 'Show', 3 => 'Other'), 'required' => false)),
      'preferred'  => new sfValidatorBoolean(array('required' => false)),
      'contact_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Contact'), 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('address[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Address';
  }

}
